/*
 * Copyright (c) 2017年11月03日  by XuanWu Wireless Technology Co., Ltd 
 *             All rights reserved  
 */
package com.zml.config;

import com.zml.entity.sync.SyncBossTask;
import com.zml.entity.sync.SysConfig;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * @author <a href="mailto:zhaominglin@wxchina.com">minglin.Zhao</a>
 * @Description
 * @Date 2017/11/3
 * @Version 1.0.0
 */
@Configuration

public class SyncTaskConfiguration {

    private static final Logger logger = LogManager.getLogger(SyncTaskConfiguration.class);

    public SyncTaskConfiguration(){
        logger.info("SyncTaskConfiguration start....");
    }

    @Bean(initMethod = "init")
    @ConfigurationProperties(prefix = "my.sysConfigTask")
    public SysConfig getSysConfig(){
        return new SysConfig();
    }

    @Bean(name = "taskExecutor")
    public ThreadPoolTaskExecutor getTaskPool(){
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.setKeepAliveSeconds(200);
        executor.setMaxPoolSize(8);
        executor.setQueueCapacity(60);
        return executor;
    }

    @Bean(initMethod = "init")
    public SyncBossTask getSyncBossTask(){
        return new SyncBossTask(this.getSysConfig());
    }
}
